import {
	MeetingOrTemplateInterfaceTwallInfo,
	StyleInfoDetail,
} from '@/pages/create/createContent/blocks/tvwall/interface'
import { PlanEntity } from '@/pages/create/createContent/blocks/tvwall/TvwallPlan/interface'
import requestMeeting, { request } from '@/plugins/axios'
import { Poll } from '../manager/poll/interface'
import { FetchTvwallStylesResponseEntity } from '../manager/tvwall/interface'
import { VmpEntity } from './vmp'

export const fetchGetAllTvwallStyles = async () =>
	requestMeeting<FetchTvwallStylesResponseEntity>({
		url: `/tvwall_styles`,
		method: 'GET',
		params: {
			start: 0,
			count: 0,
			position: 1,
			order: 1,
		},
	}).then((res) => res)
/**获取详情 */
export const fetchGetStyleById = async (id: string) =>
	request<StyleInfoDetail>({
		url: `/tvwall_styles/${id}?status=1`,
		method: 'GET',
	}).then((res) => res)
/** 获取电视墙预案列表 */
export const fetchGetTvwallPlanList = async (preKey: string, isTemplete: boolean) =>
	requestMeeting<Array<PlanEntity>>({
		url: !isTemplete
			? `/meetings/${preKey}/pretvwalls?count=0`
			: `/personal_templates/${preKey}/pretvwalls?count=0`,
		method: 'get',
	}).then((res) => res)

/**获取预案详情数据 */
export const fetchGetTvwallPlanDetail = async (preKey: string, isTemplete: boolean, id: string) =>
	request<MeetingOrTemplateInterfaceTwallInfo>({
		url: !isTemplete ? `/meetings/${preKey}/pretvwalls/${id}` : `/personal_templates/${preKey}/pretvwalls/${id}`,
		method: 'get',
	}).then((res) => res)
/**删除预案 */
export const fetchDeleteTvwallPlan = async (preKey: string, isTemplete: boolean, id: string) =>
	requestMeeting({
		url: !isTemplete ? `/meetings/${preKey}/pretvwalls/${id}` : `/personal_templates/${preKey}/pretvwalls/${id}`,
		method: 'DELETE',
	}).then((res) => res)
/**更新预案 */
export const fetchUpdateTvwallPlan = async (preKey: string, isTemplete: boolean, id: string, params: any) =>
	requestMeeting({
		url: !isTemplete ? `/meetings/${preKey}/pretvwalls/${id}` : `/personal_templates/${preKey}/pretvwalls/${id}`,
		method: 'post',
		data: params,
	}).then((res) => res)
/**新增预案 */
export const fetchSaveTvwallPlan = async (preKey: string, isTemplete: boolean, params: any) =>
	requestMeeting({
		url: !isTemplete ? `/meetings/${preKey}/pretvwalls` : `/personal_templates/${preKey}/pretvwalls`,
		method: 'post',
		data: params,
	}).then((res) => res)
/** 获取轮询预案列表 */
export const fetchGetPollPlanList = async (preKey: string, isTemplete: boolean) =>
	requestMeeting<
		{
			id: string
			name: string
		}[]
	>({
		url: `${isTemplete ? '/personal_templates' : '/meetings'}/${preKey}/prepolls?count=0`,
		method: 'GET',
	}).then((res) => res)
export const fetchGetPollPlanDetail = async (preKey: string, isTemplete: boolean, id: string) =>
	request<Poll>({
		url: isTemplete ? `/meetings/${preKey}/prepolls/${id}` : `/personal_templates/${preKey}/prepolls/${id}`,
		method: 'GET',
	}).then((res) => res)
